<?php
@session_start();
include "../../../jerimum/classes/bd.php";
include "../../../jerimum/classes/anuncios.php";

$_anu	= new anuncios(); #CLASSES

#SETA CLIENTE
$_anu->cliente	= $_SESSION['idcliente'];

#LISTA TODOS OS ANUNCIOS ATIVOS
$_anu->ativo	= 1;
$totalanuncios	= $_anu->numeroanuncio();

###############################################
#LISTA TODOS OS ANUNCIOS ATIVOS################
$where			= "WHERE cliente = '".$_SESSION['idcliente']."' ";
$order			= " ORDER BY id ";
$limit			= "";
$dadostotal	= $_anu->lista($where,$order,$limit);
###############################################
###############################################

//print_r($_SESSION);

?>

<style type="text/css">
#TableDestalhes{ border:solid 1px #CCCCCC; border-collapse:collapse}
#TableDestalhes tr td {border:1px solid #CCCCCC; padding:4px}
</style>
<style type="text/css">
<!--
.span-verde {color:#0C0
}
-->
</style>
<table width="528" id="TableDestalhes">
   
  <tr bgcolor="#F9F9F9">
  <td colspan="3"><div style="font-size:16px">Visualizações <span class="span-vermelho">> Total</span> (<?=$_anu->pegatotaldevisual()?>)</div>
  </td>
  </tr>	
    
  <tr>
    <td width="46" align="left" valign="top"><h3 style="font-weight:normal; margin:0px">COD</h3></td>
    <td width="265" align="left" valign="top"><h3 style="font-weight:normal; margin:0px">NOME DO ANÚNCIO</h3></td>
    <td width="201" align="right" valign="top"><h3 style="font-weight:normal; margin:0px">VISUALIZA&Ccedil;&Otilde;ES/STATUS</h3></td>
  </tr>
  
  <?php if(count($dadostotal)==0){	?>
  
  <tr>
    <td colspan="2" align="left" valign="top" class="span-vermelho">Não existem anúncios ativo.</td>
  </tr>
  
  <? }else{
	
	$z	= 0;
	foreach($dadostotal as $dados){ 
	$z%2 == 0?$corfundo = "#FFFFFF":$corfundo = "#F9F9F9";
	$_anu->id	= $dados["id"];
	$visualizacao	= $_anu->exibevisualizacoes();
	
	?>
  
  <tr bgcolor="<?=$corfundo?>">
    <td class="span-azul"><?=$dados['id']?></td>
    <td align="left" valign="top" class="span-azul"><?=$dados['titulo']?></td>
    <td align="right" valign="top">
    <span style="color:#00F"><?=$visualizacao?></span>/<?php if($dados["ativo"]==1){?><span class="span-verde">ativo</span><? }elseif($dados["ativo"]==2){ ?><span class="span-vermelho">finalizado</span><? }else{ ?><span class="span-vermelho">desativado</span><? } ?>
    </td>
    
  </tr>
  
  <? $z++; }} ?>
  
  
</table>